/* -----------------------------------------------------------------------
 * Card Test 4 = Testing Steward card
 * Using provided template for testUpdateCoins.c
 *
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <stdlib.h>

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

void testSteward() {
    //Game setup
    int i;
    int seed = 1000;
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;

    //Card effect setup
    int card = steward;
    int handPos = 1;
    int choice1;
    int choice2 = 0;
    int choice3 = 0; 
    //Bonus setup, irrelevant to test
    int b = 0;
    int *bonus;
    bonus = &b;
    
    printf ("TESTING playing 'steward':\n");

    for (i = 0; i < 3; i++) {
        initializeGame(numPlayer, k, seed, &G);
        int initHand = G.handCount[0]; 
        int initCoins = 0;
        G.coins = initCoins;

        if ((i = 0)) { //Choice 1 = 1
            choice1 = 1;
            
#if (NOISY_TEST == 1)
            printf("Test player %d prior to playing steward has %d hand card(s). %d cards expected.\n", 0, G.handCount[0], initHand);
#endif            
            assert(G.handCount[0] == initHand);
            //Play steward card
            cardEffect(card, choice1, choice2, choice3, &G, handPos, bonus);

#if (NOISY_TEST == 1)
            printf("Test player %d after playing steward has %d hand card(s). %d cards expected.\n", 0, G.handCount[0], initHand+1);
#endif
            assert(G.handCount[0] == initHand+1); //+2 add card, -1 play card
        }

        else if ((i = 1)) { //Choice 1 = 2
            choice1 = 2;
            
#if (NOISY_TEST == 1)
            printf("Test player %d prior to playing steward has %d coin(s). %d coin(s) expected.\n", 0, G.coins, initCoins);
#endif            
            assert(G.coins == initCoins);
            assert(G.handCount[0] == initHand); 
            //Play steward card
            cardEffect(card, choice1, choice2, choice3, &G, handPos, bonus);

#if (NOISY_TEST == 1)
            printf("Test player %d after playing steward has %d coin(s). %d coin(s) expected.\n", 0, G.coins, initCoins+2);
#endif
            assert(G.coins == initCoins+2); //+2 coins
            assert(G.handCount[0] == initHand-1); //-1 play card
        }

        else { //Choice 1 = 3
            choice1 = 3;
            
#if (NOISY_TEST == 1)
            printf("Test player %d prior to playing steward has %d hand card(s). %d cards expected.\n", 0, G.handCount[0], initHand);
#endif            
            assert(G.handCount[0] == initHand);
            //Play steward card
            cardEffect(card, choice1, choice2, choice3, &G, handPos, bonus);

#if (NOISY_TEST == 1)
            printf("Test player %d after playing steward has %d hand card(s). %d cards expected.\n", 0, G.handCount[0], initHand-3);
#endif
            assert(G.handCount[0] == initHand-3); //-2 trash card, -1 play card
        }
    }
    

    printf("All tests passed!\n");
}



int main() {
    testSteward();
    return 0;
}
